//
//  XMJobCell.m
//  XMJJ_zml
//
//  Created by 丁浩 on 2025/5/21.
//

#import "XMJobCell.h"

@interface XMJobCell ()

@property (nonatomic, strong) UIButton *itemBtn;

@end

@implementation XMJobCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self creatUI];
    }
    return self;
}

- (void)creatUI {
    [self.contentView addSubview:self.itemBtn];
}

- (void)itemSelectAction:(UIButton *)button {
    self.itemSelectBlock ? self.itemSelectBlock() : nil;
}

- (void)setContentWithTitle:(NSString *)title select:(BOOL)select {
    [_itemBtn setTitle:title forState:UIControlStateNormal];
    _itemBtn.selected = select;
}

#pragma mark - Init
- (UIButton *)itemBtn {
    if (!_itemBtn) {
        _itemBtn = [UIButton buttonWithType:UIButtonTypeCustom font:KFontSize(13.0) frame:CGRectMake(0, 0, KScaleWidth(102.0), KScaleWidth(51.0)) title:@"开发工程师" titleColor:kColorHEX(0x999999)];
        _itemBtn.titleLabel.numberOfLines = 0;
        [_itemBtn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentCenter];
        [_itemBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, KScaleWidth(5.0), 0, KScaleWidth(5.0))];
        [_itemBtn setBackgroundImage:[UIImage imageWithColor:kColorHEX(0xF3F3F3)] forState:UIControlStateNormal];
        [_itemBtn setBackgroundImage:[UIImage imageWithColor:kColorHEX(0xFDF7E7)] forState:UIControlStateSelected];
        [_itemBtn setTitleColor:kColorHEX(0xFF9D00) forState:UIControlStateSelected];
        [_itemBtn setCornerRadius:KScaleWidth(8.0)];
        [_itemBtn addTarget:self action:@selector(itemSelectAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _itemBtn;
}

@end
